package com.alibaba.dubbo.wrapper;

/**
 *
 *  Dubbo Service Wrapper 源码整理
 *
 *  每一个服务提供者getInvoker 的 Service 根据字节码都会生成一个Wrapper，该Wrap都会对Service中的方法建立索引，实现方法的非反射调用。
 *
 * @author zhangjuntao
 * @create 2017-10-26 下午6:01
 **/
public class WrapperSource {

    /**
     *
     * @param $1
     * @param $2
     * @return
     */
    public Object getPropertyValue(Object $1, String $2) {
        com.alibaba.dubbo.demo.DemoService w;
        try {
            w = ((com.alibaba.dubbo.demo.DemoService) $1);
        } catch (Throwable e) {
            throw new IllegalArgumentException(e);
        }
        throw new com.alibaba.dubbo.common.bytecode.NoSuchPropertyException("Not found property \"" + $2 + "\" filed or setter method in class com.alibaba.dubbo.demo.DemoService.");
    }

    /**
     *
     * @param $1
     * @param $2
     * @param $3
     */
    public void setPropertyValue(Object $1, String $2, Object $3) {
        com.alibaba.dubbo.demo.DemoService w;
        try {
            w = ((com.alibaba.dubbo.demo.DemoService) $1);
        } catch (Throwable e) {
            throw new IllegalArgumentException(e);
        }
        throw new com.alibaba.dubbo.common.bytecode.NoSuchPropertyException("Not found property \"" + $2 + "\" filed or setter method in class com.alibaba.dubbo.demo.DemoService.");
    }

    /**
     *              wrapper.invokeMethod(proxy, methodName, parameterTypes, arguments);
     * @param $1
     * @param $2
     * @param $3
     * @param $4
     * @return
     * @throws java.lang.reflect.InvocationTargetException
     */
    public Object invokeMethod(Object $1, String $2, Class[] $3, Object[] $4) throws java.lang.reflect.InvocationTargetException {
        com.alibaba.dubbo.demo.DemoService w;
        try {
            w = ((com.alibaba.dubbo.demo.DemoService) $1);
        } catch (Throwable e) {
            throw new IllegalArgumentException(e);
        }
        try {
            if ("sayHello".equals($2) && $3.length == 1) {
                return (Object) w.sayHello((java.lang.String) $4[0]);
            }
        } catch (Throwable e) {
            throw new java.lang.reflect.InvocationTargetException(e);
        }
        throw new com.alibaba.dubbo.common.bytecode.NoSuchMethodException("Not found method \"" + $2 + "\" in class com.alibaba.dubbo.demo.DemoService.");
    }

}
